//
//  YHPRetweetedView.swift
//  SinaSwift
//
//  Created by Yan on 16/3/26.
//  Copyright © 2016年 baidu. All rights reserved.
//

import UIKit
import SnapKit

class YHPRetweetedView: UIView {

    var retweetStatus: YHPStatus? {
        didSet {
            //绑定数据
            retweetLabel.text = retweetStatus?.text
            pictureView.imageURLs = retweetStatus?.imageURLs
        }
    }
    
    //构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    //XIB警告方法
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置UI界面
    private func setupUI () {
        
        //添加子控件
    self.addSubview(retweetLabel)
    self.addSubview(pictureView)
        
        //设置约束
        retweetLabel.snp_makeConstraints { (make) in
            make.top.left.equalTo(self).offset(commonMargin)
            make.right.equalTo(self.snp_right).offset(-commonMargin)
        }
        pictureView.snp_makeConstraints { (make) in
            make.left.equalTo(retweetLabel.snp_left)
            make.top.equalTo(retweetLabel.snp_bottom).offset(commonMargin)
            make.size.equalTo(CGSizeMake(100, 100))
        }
        self.snp_makeConstraints { (make) in
            make.bottom.equalTo(pictureView.snp_bottom).offset(commonMargin)
        }
    }
    //懒加载子视图
    lazy var retweetLabel: UILabel = UIFactory.factoryLabelWith("勿忘初心,方得始终.勿忘初心,方得始终.勿忘初心,方得始终.勿忘初心,方得始终.勿忘初心,方得始终.勿忘初心,方得始终.勿忘初心,方得始终.勿忘初心,方得始终.勿忘初心,方得始终.", textColor: UIColor.darkGrayColor(), fontSize: 14, alignment: .Left)
    lazy var pictureView: YHPStatusPictureView = YHPStatusPictureView()
    
}



